import apiMixin from '@/mixin/apiMixin';
import taskMixin from '@/mixin/taskMixin';

import utils from '@/utils/index';
export default {
    mixins: [apiMixin,taskMixin],
    data() {
        return {
            tableData:[],
            searchTypeList: [
                { value: "publish_user_name", name: "举报人昵称" },
                { value: "id", name: "仲裁id" },
                { value: "task_accept_id", name: "接单id" },
                { value: "publish_user_id", name: "举报人ID" },
                { value: "accept_user_id", name: "被举报人ID" },
                { value: "publish_user_tel", name: "举报人手机号" },
                { value: "accept_user_name", name: "被举报人昵称" },
                { value: "accept_user_tel", name: "被举报人手机号" }
            ],
            searchType: 'publish_user_name',
            searchText: '',
            listNumsTotal: 0,
            loading: false,
            curPage: 1,
            status: [
                {
                    text: '待处理',
                    value: '0'
                },
                {
                    text: '派单人胜',
                    value: '1'
                },
                {
                    text: '接单人胜',
                    value: '2'
                },
                {
                    text: '派单人复审',
                    value: '3'
                },
                {
                    text: '接单人复审',
                    value: '4'
                },
                {
                    text: '双方复审',
                    value: '5'
                },
                {
                    text: '判平/释放任务',
                    value: '6'
                },
                {
                    text: '判平/清算任务',
                    value: '7'
                }
            ],
            multipleSelection: [],
            handleShow: false,
               // 仲裁弹窗状态
            atPopStatus: -1,
            atPopText: '',
            dispostBtnLoad: false
        }
    },
    mounted() {
        this.getArbitrationListApi(this.curPage);
        if (this.filterStatus == 0 || this.filterStatu) {
            this.$refs.filterTable.columns[5].filteredValue = this.filterStatus.split(',');
        }
    },
    methods: {
        changePage(page){
            page = page || 1;
            this.getArbitrationListApi(page);
        },
        searchWill() {
            this.getArbitrationListApi();
        },
        getArbitrationListApi(page) {
            let _self = this;
            this.comResquest(this.request.getArbitrationList,(res)=>{
                console.log(res);
                let { result,count } = res;
                _self.listNumsTotal = count;
                _self.tableData = result;
                _self.curPage = Number(page) || 1;
                _self.updateRoutePar(page);
            },{
                page: page,
                load: true,
                keyword: this.searchText,
                type: this.searchType,
                status: this.filterStatus
            })
        },
        handleFilter(e) {
            console.log( e.status);
            this.filterStatus = e.status.join(',');
            this.getArbitrationListApi(1);
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        startMoreHandle() {
            if (this.multipleSelection.length <= 0) {
                this.$message.warning("未选择");
                return;
            }
            this.handleShow = true;
        },
        changeAtPopText(atIndex) {
            let str = '';
            switch (atIndex) {
                case 1:
                    str =
                        "经过检查，目前已核实接单人做的任务确实未达标，现将仲裁判定派单人胜利！";
                    break;
                case 2:
                    str =
                        "经过检查，目前已核实派单人申请的仲裁确实有误，现将仲裁判定接单人胜利！";
                    break;
                case 3:
                    str =
                        "经过检查，目前无法判定接单人任务是否未完成，现需要派单人上传复审材料以便客服审核，请注意上传能够证明的材料。";
                    break;
                case 4:
                    str =
                        "经过检查，目前无法判定接单人任务是否完成，现需要接单人上传复审材料以便客服审核，请注意上传能够证明的材料。";
                    break;
                case 5:
                    str =
                        "经过检查，目前无法判定仲裁，现需要双方上传各自的复审材料以便审核。";
                    break;
                case 6:
                    str =
                        "经过检查，目前发现双方均无异常，任务将重新释放出去。";
                    break;
                case 7:
                    str =
                        "经过检查，目前发现双方均无异常，任务将被清算退款至派单人。";
                    break;
                default:
                    str = "";
            };
            this.atPopText = str;
        },
        postDisposeArbitrationApi() {
            if (this.atPopStatus == -1) {
                this.$message.warning("未选择处理结果");
                return;
            }
            if (!this.atPopText) {
                this.$message.warning("未填写处理原因");
                return;
            }
            let ids = [];
            this.multipleSelection.forEach(element => {
                ids.push(element.id);
            });
            let _self = this;
            if (this.dispostBtnLoad) {
                return;
            }
            this.comResquest(this.request.postDisposeArbitration,(res)=>{
                _self.$notify.info({
                    title: '审批结果',
                    message: res.info
                });
                _self.handleShow = false;
                _self.getArbitrationListApi(_self.curPage);
            },{
                ids: ids,
                status: this.atPopStatus,
                remark: this.atPopText,
                load: "dispostBtnLoad"
            }); 
        },
    },
}